/*
 * @lc app=leetcode.cn id=933 lang=typescript
 *
 * [933] 最近的请求次数
 */

// @lc code=start
class RecentCounter {
    constructor() {}
    private stack: number[] = [];
    ping(t: number): number {
        this.stack.push(t);
        return this.stack.reduce((col, cur) => {
            if (cur >= t - 3000) return col + 1;
            return col;
        }, 0);
    }
}

/**
 * Your RecentCounter object will be instantiated and called as such:
 * var obj = new RecentCounter()
 * var param_1 = obj.ping(t)
 */
// @lc code=end
